package com.lele.js;

import java.io.IOException;

import com.lele.util.FolderUtil;

public class ControllerJS extends SuperJS {
	public ControllerJS(SuperJS sf){
		this.entityName = sf.getEntityName();
		this.entityClass = sf.getEntityClass();
		this.file_url = sf.getProject_root()+"leleCMS\\WebRoot\\admin\\FMApp\\"+entityClass+"App\\controller\\"+entityClass+"Ctrl.js";
		this.fields = sf.getFields();
	}
	public String getFileURL() {
		return file_url;
	}
	public String getContent() {
		StringBuilder s = new StringBuilder();
		String build = System.getProperty("user.dir")
				+ "\\src\\template\\RoleCtrl.txt";
		try {
			s.append(FolderUtil.readTxt(build.toString(), "UTF-8")
					.replace("Role", entityClass)
					.replace("role", entityName));
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		return s.toString();
	}
}
